<?php 
function chonSanPham($dongsp){
	$sqlstr=mysql_query("Select * From sanpham Where"." ".$dongsp."= MaDongSanPham");
	
	if(mysql_num_rows($sqlstr)>0){
		while($row=mysql_fetch_array($sqlstr)){
			$sqlstr2=mysql_query("Select * From daphuongtien Where MaDaPhuongTien='".$row['MaSanPham']."'");
			$row2=mysql_fetch_array($sqlstr2);
			if($row['Moi'])
				$new="new";
			else $new="";
			if($row['DacBiet'])
				$special="special";
			else $special="";			
			if($row2){
?>
            <ul><li>
                	<a href="/banhang/dienthoai/chitiet/chitiet.php?sp=<?php echo $row['MaSanPham'];?>&nsx=<?php echo $row['MaNhaSanXuat'];?>" title="<?php echo $row['TuaSanPham'];?>">
                    	<img src="<?php echo $row2['HinhAnh1'];?>" alt="<?php echo $row['TuaSanPham'];?>"/>
                    </a>
                    <div class="mname">
                        <div class="extra <?php echo $special;?>"><?php echo $special;?></div>
                        <div class="extra <?php echo $new;?>"><?php echo $new;?></div>
                        <div class="tensp">
                            <strong><?php echo $row['TenSanPham'];?>
                            </strong>
                        </div>
                   </div>
                   <div class="gia">
                        <span><?php echo $row['Gia']." VNĐ";?></span>
                   </div>
			</li></ul>
<?php
			}
			else{
?>
				<ul><li>
                	<a href="/banhang/dienthoai/chitiet/chitiet.php?sp=<?php echo $row['MaSanPham'];?>&nsx=<?php echo $row['MaNhaSanXuat'];?>" title="<?php echo $row['TuaSanPham'];?>">
                    	<img src="<?php echo "anh";?>" alt="<?php echo substr($row['TenSanPham'],11);?>"/>
                    </a>
                    <div class="mname">
                        <div class="extra <?php echo $special;?>"><?php echo $special;?></div>
                        <div class="extra <?php echo $new;?>"><?php echo $new;?></div>
                        <div class="tensp">
                            <strong><?php echo $row['TenSanPham'];?>
                            </strong>
                        </div>
                   </div>
                   <div class="gia">
                        <span><?php echo $row['Gia']. "VNĐ";?></span>
                   </div>
				</li></ul>
<?php			
			}
		}
	}
}
?>
<?php
function chonDongSanPham(){
	$sqlstr=mysql_query("Select * From dongsanpham Where TenDongSanPham<>'Khác'");
	
	if(mysql_num_rows($sqlstr)>0){
		while($row=mysql_fetch_array($sqlstr)){
?>
			<div id="title_center">
            	<h1><?php echo $row['TenDongSanPham'];?></h1>
            </div>
			<div id="content">
            	<div class="mobile">
					<?php chonSanPham($row['MaDongSanPham'])?>	
				</div>
            </div>
<?php	
		}
	}
}
?>
